Function Reference

_DateAdd

Calculates a new date based on a given date and add an interval.

#include <Date.au3>
_DateAdd ( $sType, $iValToAdd, $sDate )

 

Parameters

$sType D = Add number of days to the given date
M = Add number of months to the given date
Y = Add number of years to the given date
w = Add number of weeks to the given date
h = Add number of hours to the given date
n = Add number of minutes to the given date
s = Add number of seconds to the given date
$iValToAdd number to be added
$sDate Input date in the format "YYYY/MM/DD[ HH:MM:SS]"

 

Return Value

Success: Newly calculated date.
Failure: 0
@Error: 0 = No error.
1 = Invalid $sType
2 = Invalid $iValToAdd
3 = Invalid $sDate

 

Remarks

The function will not return an invalid date.
e.g When 3 months are added to '2004/1/31' then the result will be 2004/04/30

 

Related

_DateDiff

 

Example


#include <Date.au3>

; Add 5 days to today
$sNewDate = _DateAdd( 'd',5, _NowCalcDate())
MsgBox( 4096, "", "Today + 5 days:" & $sNewDate )

; Subtract 2 weeks from today
$sNewDate = _DateAdd( 'w',-2, _NowCalcDate())
MsgBox( 4096, "", "Today minus 2 weeks: " & $sNewDate )

; Add 15 minutes to current time
$sNewDate = _DateAdd( 'n',15, _NowCalc())
MsgBox( 4096, "", "Current time +15 minutes: " & $sNewDate )

; Calculated eventlogdate which returns second since 1970/01/01 00:00:00
$sNewDate = _DateAdd( 's',1087497645, "1970/01/01 00:00:00")
MsgBox( 4096, "", "Date: " & $sNewDate )